clear
set type double
set more 1

capture log using log/TableB2.log, replace
*produces Table B2 
*share_other: note that 70% obs are 0/1 (euro or noneuro) only 8.3% of obs are between 0.2 and 0.8
*The fractional ones that are greater than 0.2 and less than 0.8 only account for 8.3% of obs in erpt regs

*******************
*stats for table 3
***************************

use ../data/xcurrencychoice_estdata, clear
*need sum stats for Ix phi phiE phiX lnL marketshare outFDI iota plus IV instruments
*keep obs same
	foreach var in Ix mphi_xeu mphi_xeu_euro mphi_xeu_other lnmemp ms mshcompetitor_other IVsh_US IVsh_CHN IVsh_other {
		drop if missing(`var')
		}

	estpost summarize Ix mphi_xeu mphi_xeu_euro mphi_xeu_other lnmemp ms mshcompetitor_other IVsh_US IVsh_CHN IVsh_other, detail

esttab using "../results/sumstats/TableB2.csv", cells("mean sd p5 p50 p95 count") title("xcurrency_choice") noobs nomtitles nonum replace
eststo clear


*sum stats for vehicle currency
*********************************************************
use ../data/xcurrencychoice_estdata, clear
	drop Ix
	merge 1:1 vat cncode cty_code year month using ../dofiles_regressions/temp/vehicle_Ix, keep(match) nogen
	rename Ix Id
estpost summarize Id , detail

esttab using "../results/sumstats/TableB2.csv", cells("mean sd p5 p50 p95 count") title("vcurrency_choice") noobs nomtitles nonum append
eststo clear

* Maybe don't need imports?
use ../data/mcurrencychoice_estdata, clear
*need sum stats for Im exshare X XE XX lnL marketshare outFDI iota plus IV instruments
estpost summarize Im mxshare_xeu mxshare_xeu_euro mxshare_xeu_other lnmemp ms_imp mshcompetitor_other IVsh_US IVsh_CHN IVsh_other, detail

esttab using "../results/sumstats/TableA3.csv", cells("mean sd p5 p50 p95 count") title("mcurrency_choice") noobs nomtitles nonum append
eststo clear


use ../data/erpt_annual_estdata, clear
*need sum stats for dp* de deD de*phi de*phiE de*phiE de*phiX de*S de*L de*ioata
foreach var in duv_k dxE dxE_phi dxE_phi_euro dxE_phi_other dxE_ms_y dxE_lnmemp dxE_share_other share_other dq dxD {
		drop if missing(`var')
		}

estpost summarize duv_k dxE dxE_phi dxE_phi_euro dxE_phi_other dxE_ms_y dxE_lnmemp dxE_share_other share_other dq dxD, detail

gen dum=share_other>0.01 & share_other<0.99
gen dum20= share_other>0.2 & share_other<0.8
tab dum
tab dum20
 
esttab using "../results/sumstats/TableB2.csv", cells("mean sd p5 p50 p95 count") title("erpt") noobs nomtitles nonum append
eststo clear




log close

